<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<!DOCTYPE html>
<html>
<head>
    <%@include file="/WEB-INF/jspf/meta/meta.jspf" %>
    <title>教室管理</title>
    <%@include file="/WEB-INF/jspf/adminPage.jspf" %>
    <script type="text/javascript"
            src="<%=request.getContextPath()%>/static/classroom/classroom.js"></script>
</head>

<script type="text/javascript">

</script>

</head>
<body>
<form id="ff" method="post">
    <table>
        <tr>
            <td>教室名称:</td>
            <td><input type="easyui-textbox" name="classroomName" id="classroomName"/></td>

        </tr>

        <tr>
            <td>教室备注:</td>
            <td><input class="easyui-textbox" type="text"
                       name="classroomInfo" data-options="multiline:true"
                       style="height: 60px"></input></td>
        </tr>
    </table>
</form>
<div>
    <a href="javascript:void(0)" class="easyui-linkbutton" onclick="submitForm()">提交</a>
    <a href="javascript:void(0)" class="easyui-linkbutton" onclick="clearForm()">清空</a>
</div>
<script>



    function submitForm() {
        $('#ff').form({
            url: "<%=request.getContextPath()%>/classroom/insertClassroom.json",
            onSubmit: function () {
                return $(this).form('enableValidation').form('validate');
            },
            success: function (data) {
                console.log(data);
                var d = typeof data == 'string' ? JSON.parse(data) : data;
                //假如后台添加成功
                $.messager.show({
                    title: '操作提示',
                    msg: d.msg,
                    timeout: 3000,
                    showType: 'slide'
                });
                if (d.code == '1') {
                    $('#ff').form('clear');
                }
            }
        });
        $('#ff').submit();
    }

    function clearForm() {
        $('#ff').form('clear');
    }
</script>

</body>
</html>